<template>
	<u-picker :show="showFliterDep" :columns="depColumns" @cancel="closePicker" closeOnClickOverlay="true"
		@confirm="selectDep" @close="closePicker" keyName="depName">
	</u-picker>
</template>

<script>
	import {
		getGradeInSchool
	} from '@/utils/gradeInSchool.js'
	import {
		deplist
	} from '@/common/http.api.js'
	export default {
		props: {
			showPicker: Boolean
		},
		data() {
			return {
				showFliterDep: false,
				depColumns: [this.getDeplist()]
			}
		},
		watch: {
			showPicker(curr, prev) {
				this.showFliterDep = curr
			}
		},
		methods: {
			async getDeplist(){
				// uni.$loading()
				let id = uni.getStorageSync('schoolId')
				const res = await deplist({
					schoolId: id
				}) // 学院列表赋值
				let depList = res.data
				depList.unshift({
					depName: "学院不限",
					depId: ''
				})
				this.depColumns[0] = depList
	
			},
			closePicker() {
				this.showFliterDep = false
				this.$emit('on-close')
			},
			selectDep(arr) {
				let department = arr.value[0].depId
				let depId = department + '' 
				let depName = arr.value[0].depName
				this.$emit('confirm',depId,depName)
			},
		}
	}
</script>

<style>
</style>
